import { defineEmits, ref, toRef, watch, onMounted, onUnmounted } from 'vue';

export function useEventListener(el,type,method){
    onMounted(()=>{
        el.addEventListener(type,method);
    })
    onUnmounted(()=>{
        el.removeEventListener(type,method);
    })
}

export function usePagination(event){
    const pageNo = ref(1);
    const pageSize = ref(10);
    const total = ref(0);
    const pageSizes = ref([10,20,50]);
    const handleSizeChange = (val: number) => {
        event();
    }
    const handleCurrentChange = (val: number) => {
        event();
    }
    return {
        pageNo,
        pageSize,
        total,
        pageSizes,
        handleSizeChange,
        handleCurrentChange
    }
}